﻿#pragma once

#include <breaking/base/no_copy_able.h>

#include <atomic>

namespace breaking
{
	/**
	 * @brief 自旋锁
	 */
	class spin_lock : public no_copy_able
	{
	public:
		spin_lock() = default;
		~spin_lock() = default;

		/**
		 * @brief 加锁
		 */
		void lock();

		/**
		 * @brief 解锁
		 */
		void unlock();

	private:
		// 锁标记
		std::atomic_flag m_flag = ATOMIC_FLAG_INIT;
	};
}